<!--
 * @Description: 
 * @Version: 1.0
 * @Author: Yuanjy
 * @Date: 2020-05-25 21:55:39
 * @LastEditors: Yuanjy
 * @LastEditTime: 2020-05-28 01:37:51
--> 
<template>
  <div class="head-container">
    <!-- 搜索 -->
    <el-input v-model="query.nick_name" clearable placeholder="用户昵称" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-button class="filter-item" size="mini" type="primary" icon="el-icon-search" @click="toQuery">搜索</el-button>
    <el-button class="filter-item" size="mini" type="primary" icon="el-icon-plus" @click="syncUserInfo">同步用户信息</el-button>
  </div>
</template>

<script>
import checkPermission from '@/utils/permission' // 权限判断函数
import eForm from './form'

export default {
  components: { eForm },
  props: {
    query: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      queryTypeOptions: [
        { key: 'id', display_name: 'ID' },
        { key: 'name', display_name: '配置名称' },
        { key: 'description', display_name: '配置描述' }
      ]
    }
  },
  methods: {
    checkPermission,
    toQuery() {
      this.$parent.page = 0
      this.$parent.init()
    },
    syncUserInfo() {
      this.$api.user.externalUser
        .syncExternalUserInfo()
        .then(res => {
          this.$notify({
            title: '同步外部联系人成功',
            type: 'success',
            duration: 2500
          })
          this.loading = false
          this.$parent.init()
        }).catch(err => {
          this.loading = false
          console.log(err)
        })
    }
  }
}
</script>
